package com.hy.service.impl;

import com.hy.bean.Department;
import com.hy.dao.DepartmentDao;
import com.hy.dao.impl.DepartmentDaoimpl;
import com.hy.service.DepartmentService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (Department)表服务实现类
 *
 * @author makejava
 * @since 2024-04-29 14:47:14
 */
@Service("departmentService")
public class DepartmentServiceImpl implements DepartmentService {
    private DepartmentDao departmentDao = new DepartmentDaoimpl();

    /**
     * 通过ID查询单条数据
     *
     * @return 实例对象
     * @param id
     */
    @Override
    public Department queryById(int id) {
        return this.departmentDao.queryById();
    }

    @Override
    public List<Department> querAll(){
        return departmentDao.queryAll();
    }


    /**
     * 新增数据
     *
     * @param department 实例对象
     * @return 实例对象
     */
    @Override
    public Department insert(Department department) {
        this.departmentDao.insert(department);
        return department;
    }

    /**
     * 修改数据
     *
     * @param department 实例对象
     * @return 实例对象
     */
    @Override
    public Department update(Department department) {
        this.departmentDao.update(department);
        return null;
    }

    /**
     * 通过主键删除数据
     *
     * @return 是否成功
     * @param id
     */
    @Override
    public boolean deleteById(int id) {
        return this.departmentDao.deleteById() > 0;
    }
}
